#pragma once
#include "IPrimitive.h"

class CNodeCSG;

class CPrimCSG : public IPrimitive
{
private:
	CNodeCSG* m_root;

	CVector3f m_normalTemp;

public:
	//constructor destructor
	CPrimCSG();
	CPrimCSG(CNodeCSG* root);
	~CPrimCSG();

	//check intersection between a ray and the primitive
	bool intersect(const CRay& ray, float& dist, bool useGlobalCoordinates);

	//check inside
	bool isInside(const CVector3f& p);

	//gives the normal in a point
	void computeNormal(const CRay& ray, float dist, CVector3f& normal)const;

	void applyViewMatrix(const CMatrix& view);
};